package ru.rchervot.sanasar.client.event;

import com.google.gwt.event.shared.GwtEvent;

public class EventUISectionsWidthChange extends GwtEvent<HandlerUISectionsWidthChange> {
	private static Type<HandlerUISectionsWidthChange> TYPE = new Type<HandlerUISectionsWidthChange>();
	
	private final int sectionsWidth;
	
	public EventUISectionsWidthChange() {
		sectionsWidth = 0;
	} //TODO why not remove ?
	
	public EventUISectionsWidthChange(int sectionsWidth) {
		this.sectionsWidth = sectionsWidth;
	}
	
	@Override
	protected void dispatch(HandlerUISectionsWidthChange handler) {
		handler.onWidthChange(this);
	}

	/**
	 * Gets the type associated with this event.
	 * 
	 * @return returns the handler type
	 */
	public static Type<HandlerUISectionsWidthChange> getType() {
		if (TYPE == null) {
			TYPE = new Type<HandlerUISectionsWidthChange>();
		}
		return TYPE;
	}

	public Type<HandlerUISectionsWidthChange> getAssociatedType() {
		return TYPE;
	}

	public int getSectionsWidth() {
		return sectionsWidth;
	}
	
	public static EventUISectionsWidthChange build(int sectionsWidth) {
		return new EventUISectionsWidthChange(sectionsWidth);
	}

}
